﻿using System;

class FunctionDelegate
{
    public delegate decimal FuncDelegate(int element);

    public static decimal SumSequence(FuncDelegate func)
    {
        decimal sum = 0;        
        int index = 1;
        while(true)
        {
            decimal prevSum = sum;
            sum += func(index);
            index++;
            decimal difference = Math.Abs(sum - prevSum);
            if (difference < 0.01M)
            {
                break;
            }
        }
        return sum;
    }
    
    
    static void Main()
    {
        FuncDelegate d = delegate(int index)
        {
            int fact = 1;
            for (int i = 2; i <= index; i++)
            {
                fact *= i;
            }
            return 1.0m / fact;
        };
        
        Console.WriteLine(SumSequence(d));
    }
}
